<?php
namespace app\home\controller;

use app\BaseController;
use app\home\model\Movies;
use app\home\model\Banner;
use app\home\model\Seo;
use think\facade\View;
use app\api\model\Usage;


class MoviePlay extends BaseController
{
    public function index()
    {
        $movies_hot = Movies::order('hot_order desc')->limit(10)->select();
        $movie_hot1 = [];
        $movie_hot2 = [];
        foreach ($movies_hot as $key => $m_h) {
            if($key < 2){
                array_push($movie_hot1, $m_h);
            }else{
                array_push($movie_hot2, $m_h);
            }
        }
        View::assign('movie_hot1', $movie_hot1);
        View::assign('movie_hot2', $movie_hot2);
        View::assign('movies', Movies::order('addtime desc')->limit(20)->select());
        View::assign('banner', Banner::getAll());
        View::assign('kw', Seo::getKeywords());
        View::assign('desc', Seo::getDesc());
        $usage = new Usage;
        $usage->save([
            'access_page'=>'Other',
            'access_time'=>date('Y-m-d', time()),
            'access_ip'=>$_SERVER["REMOTE_ADDR"]
        ]);
        return View::fetch();
    }
    public function iframe()
    {
        $vid = $_GET['vid'];
        $video = Movies::field("content")->where("id=".$vid)->find();
        View::assign("src", $video['content']);
        return View::fetch();
    }
}
